<template>
    <div>
        <el-card shadow="never">
            <vxe-grid ref='xGrid' v-bind="gridOptions" v-on="gridEvent">
                <template #action="{ row }">
                    <el-popconfirm title="确定同意退会?" @confirm="confirmQuit(row)" @cancel="cancelQuit(row)">
                        <template #reference>
                            <el-button :disabled="row.agree == 1" type="danger" plain>执行</el-button>
                        </template>
                    </el-popconfirm>
                </template>
            </vxe-grid>
        </el-card>
    </div>
</template>

<script setup lang="ts">
import { http } from '@/plugins/axios'
const xGrid = ref()
const { gridOptions } = useQuit();
const gridEvent: VxeGridListeners<RowVO> = {
    proxyQuery() {
        console.log('数据代理查询事件')
    },
    proxyDelete() {
        console.log('数据代理删除事件')
    },
    proxySave() {
        console.log('数据代理保存事件')
    }
}
const confirmQuit = async (row: any) => {
    await http.request({
        url: `/quitreason/${row.id}`,
        method: 'PUT',
        data: {
            user_id: row.user_id,
            agree: true
        }
    })
    xGrid.value.commitProxy('reload')
}
const cancelQuit = async (row: any) => {
    await http.request({
        url: `quitreason/${row.id}`,
        method: 'PUT',
        data: {
            user_id: row.user_id,
            agree: false
        }
    })
    xGrid.value.commitProxy('reload')
}
</script>

<style scoped></style>